This notebook demonstrates how BioThings Explorer is able to transform any JSON response from API into biolink-compatible JSON structure using the built-in JSON Transform module.

Below list two examples:

  1. Transformation of output from DISEASES API.
  2. Transformation of output from Stanford BioSample API.

Use Case 1: DISEASES API

Step 1: Fetch API response from DISEASES API


In [1]:
import requests
json_doc = requests.get('http://pending.biothings.io/diseases/disease/MONDO:0019280').json()

In [2]:
json_doc


Out[2]:
{'DISEASES': {'associatedWith': [{'category': 'textmining',
    'confidence': 2.463,
    'symbol': 'KCNJ8',
    'zscore': 4.927},
   {'category': 'textmining',
    'confidence': 2.455,
    'symbol': 'UROD',
    'zscore': 4.91},
   {'category': 'textmining',
    'confidence': 1.533,
    'symbol': 'EPC2',
    'zscore': 3.065},
   {'category': 'textmining',
    'confidence': 2.659,
    'symbol': 'ABCC9',
    'zscore': 5.317},
   {'category': 'textmining',
    'confidence': 1.912,
    'symbol': 'MYOM2',
    'zscore': 3.824},
   {'category': 'textmining',
    'confidence': 1.614,
    'symbol': 'SMARCB1',
    'zscore': 3.229},
   {'category': 'textmining',
    'confidence': 1.647,
    'symbol': 'CPOX',
    'zscore': 3.294},
   {'category': 'textmining',
    'confidence': 1.644,
    'symbol': 'SRD5A3',
    'zscore': 3.288},
   {'category': 'textmining',
    'confidence': 1.55,
    'symbol': 'CLDN16',
    'zscore': 3.1},
   {'category': 'textmining',
    'confidence': 1.697,
    'symbol': 'SMARCA2',
    'zscore': 3.395},
   {'category': 'textmining',
    'confidence': 1.754,
    'symbol': 'KCNH1',
    'zscore': 3.508},
   {'category': 'textmining',
    'confidence': 1.767,
    'symbol': 'ATP6V1B2',
    'zscore': 3.533},
   {'category': 'textmining',
    'confidence': 1.934,
    'symbol': 'NIPBL',
    'zscore': 3.869},
   {'category': 'textmining',
    'confidence': 1.597,
    'symbol': 'TMEM184C',
    'zscore': 3.195},
   {'category': 'textmining',
    'confidence': 1.551,
    'symbol': 'IGF1',
    'zscore': 3.102},
   {'category': 'textmining',
    'confidence': 1.902,
    'symbol': 'INSR',
    'zscore': 3.803},
   {'category': 'textmining',
    'confidence': 2.16,
    'symbol': 'ABCC8',
    'zscore': 4.321},
   {'category': 'textmining',
    'confidence': 1.61,
    'symbol': 'BANF1',
    'zscore': 3.219},
   {'category': 'textmining',
    'confidence': 1.615,
    'symbol': 'KIAA0195',
    'zscore': 3.229},
   {'category': 'textmining',
    'confidence': 1.719,
    'symbol': 'SMC1A',
    'zscore': 3.438},
   {'category': 'textmining',
    'confidence': 1.894,
    'symbol': 'SMARCE1',
    'zscore': 3.787},
   {'category': 'textmining',
    'confidence': 2.273,
    'symbol': 'ARID1B',
    'zscore': 4.546},
   {'category': 'textmining',
    'confidence': 1.966,
    'symbol': 'KCNJ11',
    'zscore': 3.933},
   {'category': 'textmining',
    'confidence': 1.605,
    'symbol': 'PES1',
    'zscore': 3.211},
   {'category': 'textmining',
    'confidence': 1.602,
    'symbol': 'FGF17',
    'zscore': 3.205},
   {'category': 'textmining',
    'confidence': 1.644,
    'symbol': 'BSCL2',
    'zscore': 3.287},
   {'category': 'textmining',
    'confidence': 1.584,
    'symbol': 'SMC3',
    'zscore': 3.169},
   {'category': 'textmining',
    'confidence': 2.653,
    'symbol': 'UROS',
    'zscore': 5.306},
   {'category': 'textmining',
    'confidence': 1.959,
    'symbol': 'PDLIM1',
    'zscore': 3.918},
   {'category': 'textmining',
    'confidence': 1.832,
    'symbol': 'AGPAT2',
    'zscore': 3.664},
   {'category': 'textmining',
    'confidence': 2.027,
    'symbol': 'SURF1',
    'zscore': 4.053},
   {'category': 'textmining',
    'confidence': 2.934,
    'symbol': 'SLC29A3',
    'zscore': 5.868},
   {'category': 'textmining',
    'confidence': 1.887,
    'symbol': 'HGSNAT',
    'zscore': 3.774},
   {'category': 'textmining',
    'confidence': 1.6,
    'symbol': 'SHBG',
    'zscore': 3.199},
   {'category': 'textmining',
    'confidence': 1.568,
    'symbol': 'NUDT14',
    'zscore': 3.135},
   {'category': 'textmining',
    'confidence': 2.235,
    'symbol': 'TRPS1',
    'zscore': 4.469},
   {'category': 'textmining',
    'confidence': 1.739,
    'symbol': 'INS',
    'zscore': 3.479},
   {'category': 'textmining',
    'confidence': 1.512,
    'symbol': 'AKAP8L',
    'zscore': 3.024},
   {'category': 'textmining',
    'confidence': 1.993,
    'symbol': 'CABIN1',
    'zscore': 3.986},
   {'category': 'textmining',
    'confidence': 1.999,
    'symbol': 'POMC',
    'zscore': 3.997},
   {'category': 'textmining',
    'confidence': 1.649,
    'symbol': 'MBD5',
    'zscore': 3.299},
   {'category': 'textmining',
    'confidence': 1.76,
    'symbol': 'SOS1',
    'zscore': 3.521},
   {'category': 'textmining',
    'confidence': 1.564,
    'symbol': 'SMARCA4',
    'zscore': 3.128},
   {'category': 'textmining',
    'confidence': 1.936,
    'symbol': 'CLEC2A',
    'zscore': 3.871},
   {'category': 'textmining',
    'confidence': 1.722,
    'symbol': 'LAX1',
    'zscore': 3.445},
   {'category': 'textmining',
    'confidence': 1.766,
    'symbol': 'KMT2A',
    'zscore': 3.532},
   {'category': 'textmining',
    'confidence': 1.592,
    'symbol': 'SLC25A24',
    'zscore': 3.185},
   {'category': 'textmining',
    'confidence': 1.632,
    'symbol': 'FOXI3',
    'zscore': 3.263}],
  'doid': 'DOID:420',
  'name': 'Hypertrichosis'},
 '_id': 'MONDO:0019280',
 '_version': 2}

Step 2: Fetch BTE response mapping file using BTE client


In [3]:
from biothings_explorer.registry import Registry
reg = Registry()

In [4]:
mapping = reg.registry['DISEASES']['mapping']

In [5]:
mapping


Out[5]:
{'@context': 'http://schema.org',
 '@type': 'DiseaseOrPhenotypicFeature',
 'bts:mondo': '_id',
 'bts:associatedWith': [{'@type': 'Gene',
   'bts:symbol': 'DISEASES.associatedWith.symbol',
   'bts:category': 'DISEASES.associatedWith.category',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'}]}

In [6]:
from biothings_explorer.json_transformer import Transformer
tf = Transformer(json_doc, mapping)
tf.transform()


Out[6]:
{'@context': 'http://schema.org',
 '@type': 'DiseaseOrPhenotypicFeature',
 'bts:mondo': ['MONDO:0019280'],
 'bts:associatedWith': [{'bts:symbol': ['KCNJ8'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['UROD'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['EPC2'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['ABCC9'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['MYOM2'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SMARCB1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['CPOX'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SRD5A3'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['CLDN16'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SMARCA2'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['KCNH1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['ATP6V1B2'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['NIPBL'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['TMEM184C'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['IGF1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['INSR'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['ABCC8'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['BANF1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['KIAA0195'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SMC1A'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SMARCE1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['ARID1B'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['KCNJ11'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['PES1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['FGF17'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['BSCL2'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SMC3'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['UROS'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['PDLIM1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['AGPAT2'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SURF1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SLC29A3'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['HGSNAT'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SHBG'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['NUDT14'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['TRPS1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['INS'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['AKAP8L'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['CABIN1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['POMC'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['MBD5'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SOS1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SMARCA4'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['CLEC2A'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['LAX1'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['KMT2A'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['SLC25A24'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'},
  {'bts:symbol': ['FOXI3'],
   'bts:category': ['textmining'],
   '@type': 'Gene',
   '$input': 'bts:mondo',
   '$source': 'DISEASES'}]}

Use Case 2: Stanford Biosample API

Step 1: Fetch API response from Stanford Biosample API


In [7]:
import requests
json_doc = requests.get('http://api.kp.metadatacenter.org/biosample/search?q=biolink:Disease=MONDO:0007915&limit=10').json()
json_doc


Out[7]:
{'pagination': {'offset': 0, 'limit': 10, 'total': 770},
 'data': [{'biosampleAccession': 'SAMEA104266365',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_12_2'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_12_2'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266365'},
  {'biosampleAccession': 'SAMEA104266477',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_83'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_83'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266477'},
  {'biosampleAccession': 'SAMEA104266517',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_151'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_151'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266517'},
  {'biosampleAccession': 'SAMEA104266529',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_33'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_33'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266529'},
  {'biosampleAccession': 'SAMEA104266535',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_159'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_159'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266535'},
  {'biosampleAccession': 'SAMEA104266574',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_85'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_85'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266574'},
  {'biosampleAccession': 'SAMEA104266605',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_115'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_115'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266605'},
  {'biosampleAccession': 'SAMEA104266733',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_138'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_138'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266733'},
  {'biosampleAccession': 'SAMEA104266739',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_50'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_50'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266739'},
  {'biosampleAccession': 'SAMEA104266779',
   'bioprojectAccession': None,
   'sampleName': None,
   'sampleTitle': 'Sample from Homo sapiens',
   'organism': 'Homo sapiens',
   'attributes': [{'attributeName': 'sample name',
     'attributeValue': 'source SLE_111'},
    {'attributeName': 'cell type',
     'attributeValue': 'peripheral blood mononuclear cell',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Cell',
     'attributeNameTermLabel': 'Cell',
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/CL_2000001',
     'attributeValueTermLabel': 'peripheral blood mononuclear cell',
     'attributeValueTermSource': 'CL'},
    {'attributeName': 'disease',
     'attributeValue': 'systemic lupus erythematosus',
     'attributeNameTermUri': 'https://w3id.org/biolink/biolinkml/meta/Disease',
     'attributeNameTermLabel': 'Disease',
     'attributeNameTermAltLabels': ['disease status', 'disease state'],
     'attributeNameTermSource': 'BIOLINK',
     'attributeValueTermUri': 'http://purl.obolibrary.org/obo/MONDO_0007915',
     'attributeValueTermLabel': 'systemic lupus erythematosus (disease)',
     'attributeValueTermAltLabels': ['sle',
      'systemic lupus erythematosus (sle)',
      'systemic lupus erythematosus'],
     'attributeValueTermSource': 'MONDO'},
    {'attributeName': 'individual', 'attributeValue': 'SLE_111'},
    {'attributeName': 'specimen with known storage state',
     'attributeValue': 'fresh specimen'}],
   'biosampleUrl': 'https://www.ncbi.nlm.nih.gov/biosample/SAMEA104266779'}],
 'biosampleAccessions': [],
 'bioprojectsAgg': {},
 'organizationsAgg': [],
 'attributesAgg': {'disease': {},
  'tissue': {},
  'cellType': {},
  'cellLine': {},
  'sex': {}}}

Step 2: Fetch BTE response mapping file using BTE client


In [8]:
from biothings_explorer.registry import Registry
reg = Registry()
mapping = reg.registry['stanford_biosample_disease2sample']['mapping']

In [9]:
mapping


Out[9]:
{'@context': 'http://schema.org',
 '@type': 'DiseaseOrPhenotypicFeature',
 'bts:mondo': 'mondo',
 'bts:diseaseAssociatedWithBiosample': [{'@type': 'Biosample',
   'bts:samd': 'data.biosampleAccession',
   'bts:organism': 'data.oorganism',
   'bts:age': 'data.attributes.age',
   'bts:sex': 'data.attributes.sex.name',
   'bts:cellline': 'data.attributes.cell_line.name',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'}]}

In [10]:
from biothings_explorer.json_transformer import Transformer

In [11]:
tf = Transformer(json_doc=json_doc, mapping=mapping)

In [12]:
tf.transform()


Out[12]:
{'@context': 'http://schema.org',
 '@type': 'DiseaseOrPhenotypicFeature',
 'bts:mondo': [],
 'bts:diseaseAssociatedWithBiosample': [{'bts:samd': ['SAMEA104266365'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266477'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266517'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266529'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266535'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266574'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266605'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266733'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266739'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'},
  {'bts:samd': ['SAMEA104266779'],
   '@type': 'Biosample',
   '$input': 'bts:mondo',
   '$source': 'NCBI Biosample Database'}]}